import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:list_test/weight.dart';

class WeightItem extends StatelessWidget {
  WeightItem(this.weight, this.weightDifference);
  final Weight weight;
  final double weightDifference;

  @override
  Widget build(BuildContext context) {
    return new Padding(
      padding: EdgeInsets.all(16.0),
      child: new Row(
        children: [
          new Expanded(
            child: new Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                new Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    new Text(
                      new DateFormat.MMMEd().format(weight.dateTime),
                      textScaleFactor: 1,
                      textAlign: TextAlign.left,
                    ),
                    new Text(
                      new DateFormat.EEEE().format(weight.dateTime),
                      textScaleFactor: 1,
                      textAlign: TextAlign.left,
                      style: new TextStyle(color: Colors.grey),
                    ),
                  ],
                ),
                (weight.note == null || weight.note.isEmpty
                  ? new Container(height: 0, width: 0,)
                  : new Padding(
                    padding: EdgeInsets.only(left: 4.0),
                    child: new Icon(
                      Icons.speaker_notes,
                      color: Colors.grey[300],
                      size: 16.0,
                    ),
                  )
                ),
              ],
            )
          ),
          new Expanded(
            child: new Text(
              weight.weight.toString(),
              textScaleFactor: 2.0,
              textAlign: TextAlign.center,
            ),
          ),
          new Expanded(
          child: new Text(
            weightDifference.toStringAsFixed(2),
            textScaleFactor: 1.6,
            textAlign: TextAlign.right,
          ),
        )
        ]
      ),
    );
  }
}
